<?php
/**
 * Author:Arthur
 * Date:2013-4-26
 * File Name:iptv_form.php
 * Email:kingarthurx@sina.cn
 */
?>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'package-form',
	'enableAjaxValidation'=>false,
)); 
/*
Yii::app()->clientScript->registerScript('admin', "
$(document).ready(function(){
		$('#Package_service_id').append('<option value=0>'+'请您选择'+'</option>');
		$('#Package_service_id option[value=0] ').attr('selected',true);
		$('#Package_package_type').change(function(){
		var package_type = $(this).val();
			if(package_type==1){
			$('#Package_service_id').hide();
			$('label:eq(4)').hide();
			}
		})
	})
")
*/
?>

	<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?></p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'package_name'); ?>
		<?php echo $form->textField($model,'package_name',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'package_name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'package_content'); ?>
		<?php
			$arr = explode('|',$model->package_content);
			$result = Package::model()->getIptvChannels($id);
			$k=0;
			for($i=0; $i<count($result); $i++){
				for($j=0; $j<count($arr); $j++){
					if($arr[$j] == $result[$i]['channel_id']){
						$k++;
					?>
					<input type="checkbox"  name="package_content[]" checked="checked" value="<?php echo $result[$i]['channel_id'];?>" /><?php echo $result[$i]['channel_name'];?>
					<?php
					}
					
				}
				if(($i+1)%5 == 0&&$i>=4){
						echo '</br >';
					}
				if($k == 0){
				?>
			<input type="checkbox"  name="package_content[]" value="<?php echo $result[$i]['channel_id'];?>" /><?php echo $result[$i]['channel_name'];?>	
		<?php
			}
			$k=0;
		}
		?>
		<?php echo $form->error($model,'package_content'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'package_price'); ?>
		$<?php echo $form->textField($model,'package_price'); ?>
		<?php echo $form->error($model,'package_price'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'package_type'); ?>
		<?php echo $form->dropDownList($model,'package_type',array('0'=>'一般套餐')); ?>
		<?php echo $form->error($model,'package_type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'service_id'); ?>
		<?php echo $form->dropDownList($model,'service_id',Package::model()->getServiceName()); ?>
		<?php echo $form->error($model,'service_id'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Create') : Yii::t('base','Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->